package com.espeaker.sdk.api;
import com.espeaker.sdk.ESpeakerParameters;
import com.espeaker.sdk.log.model.AppLaunchLog;
import com.espeaker.sdk.log.model.CartLog;
import com.espeaker.sdk.log.model.ClickFlowLog;
import com.espeaker.sdk.log.model.DeviceLog;
import com.espeaker.sdk.log.model.LoginLog;
import com.espeaker.sdk.log.model.RecordLog;

public class LogPostApi extends LogApi{
	/*
	 * 应用启动
	 */
	public void app_launch(final AppLaunchLog log) {
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", log.user_id,true);
					params.add("phone_number", log.phone_number,true);
					params.add("net_type", log.net_type,true);
					params.add("app_version", log.app_version,true);
					params.add("ip", log.ip,true);
					params.add("datasource", DataSource,true);
					request(URL_BASE, LOG_APP_LAUNCH, params);
				} catch (Exception er) {
				}
			}
		}.start();
	}
	/*
	 * 加入购物车
	 */
	public void cart(final CartLog log)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", log.user_id,true);
					params.add("phone_number", log.phone_number,true);
					params.add("record_id", log.record_id,true);
					params.add("audio_length", log.audio_length,true);
					params.add("tiku_type", log.tiku_type,true);
					params.add("tiku_title", log.tiku_title,true);
					params.add("is_add", log.is_add,true);
					request(URL_BASE, LOG_CART, params);
				} catch (Exception er) {
				}
			}
		}.start();
	}
	/*
	 * 点击按钮
	 */
	public void clickFlow(final ClickFlowLog log)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", log.user_id,true);
					params.add("phone_number", log.phone_number,true);
					params.add("tiku_type", log.tiku_type,true);
					params.add("tiku_title", log.tiku_title,true);
					params.add("datasource", DataSource,true);
					params.add("button_name", log.button_name,true);
					request(URL_BASE, LOG_CLICK, params);
				} catch (Exception er) {
				}
			}
		}.start();
	}
	/*
	 * 设备
	 */
	public void device(final DeviceLog log)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", log.user_id,true);
					params.add("phone_number", log.phone_number,true);
					params.add("resolution", log.resolution,true);
					params.add("serial_number", log.serial_number,true);
					params.add("cpu", log.cpu,true);
					params.add("app_version", log.app_version,true);
					params.add("net_type", log.net_type,true);
					params.add("os_message", log.os_message,true);
					params.add("phone_model", log.phone_model,true);
					params.add("ip", log.ip,true);
					params.add("datasource", DataSource,true);
					request(URL_BASE, LOG_DEVICE, params);
				} catch (Exception er) {
				}
			}
		}.start();
	}
	/*
	 * 登录
	 */
	public void login(final LoginLog log)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", log.user_id,true);
					params.add("phone_number", log.phone_number,true);
					params.add("lat", log.lat,true);
					params.add("lau", log.lau,true);
					params.add("address", log.address,true);
					params.add("ip", log.ip,true);
					params.add("datasource", DataSource,true);
					request(URL_BASE, LOG_LOGIN, params);
				} catch (Exception er) {
				}
			}
		}.start();
	}
	/*
	 * 语音
	 */
	public void record(final RecordLog log)
	{
		new Thread() {
			@Override
			public void run() {
				try {
					ESpeakerParameters params = new ESpeakerParameters();
					params.add("user_id", log.user_id,true);
					params.add("phone_number", log.phone_number,true);
					params.add("record_id", log.record_id,true);
					params.add("audio_length", log.audio_length,true);
					params.add("tiku_type", log.tiku_type,true);
					params.add("tiku_title", log.tiku_title,true);
					request(URL_BASE, LOG_RECORD, params);
				} catch (Exception er) {
				}
			}
		}.start();
	}
}
